export default {
    bind: function (el, binding) {
        //说明指令的bind函数狗子
        // el是节点 使用这个指令节点
        // binding获取指令传递过来的数据

        const options = binding.value
        const { className, activeClass, activeIndex } = options
        // console.log({ className, activeClass, activeIndex });
        // 获取item节点 item数据
        const children = el.getElementsByClassName(className);
        children[activeIndex].className += ` ${activeClass}`
    },
    update: function (el, binding) {
        // 点击时候触发
        // 获取这一次配值
        const options = binding.value;
        // 获取上一次的配置
        const oldOptions = binding.oldValue;

        // console.log(options,oldOptions);
        const { className, activeClass, activeIndex } = options;
        // const { activeIndex:oldIndex } = oldOptions
        const  oldIndex  = oldOptions. activeIndex
        // console.log(className, activeClass, activeIndex);
        // console.log(  oldIndex);
        // console.log( activeIndex,oldIndex);
        const children = el.getElementsByClassName(className);
        children[activeIndex].className += ` ${activeClass}`
        children[oldIndex].className = className
    }
}